﻿using System;
using System.Collections.Generic;
using PortalCurriculo.Domain;

namespace PortalCurriculo.WebUI.Helpers
{
    public class GeneralAccess : PageHelper
    {
        protected override void OnLoad(EventArgs e)
        {
            VerifyAccess();
            base.OnLoad(e);
        }

        private void VerifyAccess()
        {
            if (UsuarioLogado == null)
                Response.Redirect(string.Concat(GeneralUser.Login, "?returnUrl=", "~"+ Request.RawUrl));
        }

        public static Usuario UserLogged
        {
            get { return (Usuario)SessionHelper.Session(SessionHelper.SessionName.UsuarioLogado); }
        }

        public static List<Link> LinksUser
        {
            get { return (List<Link>)SessionHelper.Session(SessionHelper.SessionName.LinksUsuario); }
        }

        public string Encription { get; set; }
    }
}